




/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：03/02/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.application.yfplacefiledownlog.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.yfplacefiledownlog.entity.YfPlacefiledownlog;
import com.application.yfplacefiledownlog.struts.form.YfPlacefiledownlogForm;
import com.application.yfplacefiledownlog.service.YfPlacefiledownlogService;
import com.application.yfplacefiledownlog.commons.Constants;
 /**
 * 
 * Description:YfPlacefiledownlogAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060    <br />
 * 
 * History: <br />
 * 
 * 03/02/2012 
 * 
 */
public class YfPlacefiledownlogAction extends DispatchAction
{
       
       /**
	 * Service层实例
	 */
	private YfPlacefiledownlogService yfPlacefiledownlogService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private YfPlacefiledownlog yfPlacefiledownlog;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getYfPlacefiledownlogPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchYfPlacefiledownlog" + "开始");
		YfPlacefiledownlogForm yfPlacefiledownlog = (YfPlacefiledownlogForm)form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List yfPlacefiledownlogList = null;
//		resultSize = yfPlacefiledownlogService.getAllCountYfPlacefiledownlog(yfPlacefiledownlog);
//		pageBean = PageBean.getPageBean("yfPlacefiledownlogTab", resultSize,request);
		yfPlacefiledownlogList = yfPlacefiledownlogService.searchYfPlacefiledownlog(yfPlacefiledownlog,pageBean);
		request.setAttribute("yfPlacefiledownlogList", yfPlacefiledownlogList);

		log.debug("searchYfPlacefiledownlog" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddYfPlacefiledownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddYfPlacefiledownlogs");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addYfPlacefiledownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addYfPlacefiledownlogs");
		YfPlacefiledownlog yfPlacefiledownlog = this.getYfPlacefiledownlog(form);
                yfPlacefiledownlog.setId(RandomKey.generateID_Long_19());
		 yfPlacefiledownlog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfPlacefiledownlog.setCreateDate(new Date());

		this.yfPlacefiledownlogService.insertObject(yfPlacefiledownlog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteYfPlacefiledownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteYfPlacefiledownlogs");
		YfPlacefiledownlogForm yfPlacefiledownlogForm = (YfPlacefiledownlogForm) form;
		this.yfPlacefiledownlogService.deleteYfPlacefiledownlogs(yfPlacefiledownlogForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateYfPlacefiledownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateYfPlacefiledownlogs");

		YfPlacefiledownlog yfPlacefiledownlog = this.getYfPlacefiledownlog(form);
		yfPlacefiledownlog = this.yfPlacefiledownlogService.getYfPlacefiledownlog(yfPlacefiledownlog);
		request.setAttribute(Constants.YFPLACEFILEDOWNLOG, yfPlacefiledownlog);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateYfPlacefiledownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateYfPlacefiledownlogs");
		YfPlacefiledownlog yfPlacefiledownlog = this.getYfPlacefiledownlog(form);
	        yfPlacefiledownlog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfPlacefiledownlog.setCreateDate(new Date());
		this.yfPlacefiledownlogService.updateObject(yfPlacefiledownlog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewYfPlacefiledownlog(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewYfPlacefiledownlog");

		YfPlacefiledownlog yfPlacefiledownlog = this.getYfPlacefiledownlog(form);
		yfPlacefiledownlog = this.yfPlacefiledownlogService.getYfPlacefiledownlog(yfPlacefiledownlog);
		request.setAttribute(Constants.YFPLACEFILEDOWNLOG, yfPlacefiledownlog);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the YfPlacefiledownlogService
	 */
	public YfPlacefiledownlogService getYfPlacefiledownlogService() {
		return this.yfPlacefiledownlogService;
	}

	/**
	 * @param YfPlacefiledownlogService
	 *  the YfPlacefiledownlogService to set
	 */
	public void setYfPlacefiledownlogService(YfPlacefiledownlogService yfPlacefiledownlogService) {
		this.yfPlacefiledownlogService = yfPlacefiledownlogService;
	}

	/**
	 * 获取YfPlacefiledownlog实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the YfPlacefiledownlog
	 */
	public YfPlacefiledownlog getYfPlacefiledownlog(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		YfPlacefiledownlogForm yfPlacefiledownlogForm = (YfPlacefiledownlogForm) form;
		yfPlacefiledownlog = new YfPlacefiledownlog();
		BeanUtils.copyProperties(yfPlacefiledownlog, yfPlacefiledownlogForm);
		return yfPlacefiledownlog;
	}
    
        public void setYfPlacefiledownlog(YfPlacefiledownlog yfPlacefiledownlog) {
		this.yfPlacefiledownlog = yfPlacefiledownlog;
	}

}
